package glickrdemo

import org.glickr.FlickrPhoto
import org.glickr.enums.ContentType
import org.glickr.enums.TagMode

class PhotoController {

    def flickrService

    def index() {
        redirect(action:'getPhotoById')
    }

    def findAll() {
        def examples = []

        examples.add([ method:'findAll', params:[text:'PCD0992',page:1,perPage:10], result:flickrService.findAll([text:'PCD0992',page:1,perPage:10]) ])
        examples.add([ method:'findAll', params:[text:'sp91052'], result:flickrService.findAll([text:'sp91052']) ])
        examples.add([ method:'findAll', params:[tags:'GlickrTest,Horizontal',tagMode:TagMode.All,contentType: ContentType.PhotosAndOther], result:flickrService.findAll([tags:'GlickrTest,Horizontal',tagMode:TagMode.All,contentType: ContentType.PhotosAndOther]) ])
        examples.add([ method:'findAll', params:[tags:'GlickrTest',contentType: ContentType.Other], result:flickrService.findAll([tags:'GlickrTest',contentType: ContentType.Other]) ])

        [examples: examples]
    }

    def getPhotoById() {
        [photo: flickrService.getPhotoById(params.long('id') ?: 7957234984)]
    }

    def getPhotoDetails() {
        FlickrPhoto photo = flickrService.getPhotoById(params.long('id') ?: 7957234984)
        photo = flickrService.getPhotoDetails(photo)
        [photo: photo]
    }

    def temp() {
        FlickrPhoto photo
        photo = flickrService.geoGetLocation(params.long('id') ?: 7957234984)
        [photo: photo]
    }
}
